# $Id$
# Maintainer:  Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: kfgz <kfgz at interia pl>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - patch to attempt fixing ARM hackery by bandwagoning developers
#  - compile with -fPIC on AArch64

pkgname=x265
pkgver=1.7
pkgrel=2
pkgdesc='Open Source H265/HEVC video encoder'
arch=('i686' 'x86_64')
url='https://bitbucket.org/multicoreware/x265'
license=('GPL')
depends=('gcc-libs')
makedepends=('yasm' 'cmake')
provides=('libx265.so')
source=($pkgname-$pkgver.tar.bz2::$url/get/$pkgver.tar.bz2
        arm.patch)
md5sums=('d6020c277b05ab44f8222342aaa9c99f'
         '9c773543b7a1f2b54f02f588725a8201')

prepare() {
  cd multicoreware-x265-*
  patch -p1 -i ../arm.patch
}

build() {
  cd multicoreware-x265-*/build/linux
  [[ $CARCH == x86_64 ]] && LDFLAGS+=',-z,noexecstack'
  [[ $CARCH == aarch64 ]] && CFLAGS+=' -fPIC' && CXXFLAGS+=' -fPIC'
  cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr ../../source
  make
}

package() {
  cd multicoreware-x265-*/build/linux
  make DESTDIR="$pkgdir" install
}
